# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

_name=asyncpg
pkgname=python-$_name
pkgver=0.27.0
pkgrel=3
pkgdesc='A fast PostgreSQL Database Client Library for Python/asyncio'
arch=('loong64' 'x86_64')
url='https://github.com/MagicStack/asyncpg'
license=('Apache')
depends=('python')
makedepends=('cython' 'python-build' 'python-installer' 'python-setuptools'
'python-wheel')
checkdepends=('python-pytest' 'python-pytest-runner' 'python-uvloop' 'postgresql')
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('66d4e16cba8ebebfa0403c7d3b1d3ee1b9b8f55a9b70f57e809d28161873d74750152e6ed548b17ceb97ca84f7a669a5fa503c824a861b295db731f86bfb0137')
b2sums=('e4fe88346a3fb4d9b6ce74a4e12db333f1aefd8844d6b08091a1e507a56754bb74dcbdd1b43329f1df24725f03c808a1862c8c4587c9ec95c4800f30ab78458c')

prepare() {
  cd $_name-$pkgver

  sed -i "s|'Cython==.*'|'Cython'|" setup.py
}

build() {
  cd $_name-$pkgver

  python -m build -nw
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver

  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  mv -v $_name $_name-off
  pytest -vv tests/
}

package() {
  cd $_name-$pkgver

  python -m installer -d "$pkgdir" dist/*.whl

  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

# vim:set ts=2 sw=2 et:
